-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(custom-openai-compatible-api-provider): extended api provider to… #2450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… connect roo to openai compatible apis that have non standard configs ustom auth headers instead of `authorization` custom or empty auth header prefixes and url structures where model is included in the path
|
src/api/providers/custom-openai.ts
Outdated
| console.error("Custom OpenAI API request failed:", error) | ||
| let errorMessage = "Custom OpenAI API request failed." | ||
| if (axios.isAxiosError(error) && error.response) { | ||
| errorMessage += ` Status: ${error.response.status}. Data: ${JSON.stringify(error.response.data)}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider refining error handling. Instead of yielding an error chunk with potential internal details (e.g. from JSON.stringify on error.response.data), it might be safer to throw an error or return a sanitized message so sensitive data isn’t inadvertently exposed.
| errorMessage += ` Status: ${error.response.status}. Data: ${JSON.stringify(error.response.data)}` | |
| errorMessage += ` Status: ${error.response.status}. Data: [REDACTED]` |
| onInput={handleInputChange("customBaseUrl")} | ||
| placeholder="https://your-custom-api.example.com" | ||
| className="w-full"> | ||
| <label className="block font-medium mb-1">Custom Base URL</label> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User-facing strings for the custom-openai settings (e.g. 'Custom Base URL', 'Custom API Key', 'Auth Header Name', 'Auth Header Prefix') are hard-coded. For internationalization compliance, wrap these strings with the translation function t.
| <label className="block font-medium mb-1">Custom Base URL</label> | |
| <label className="block font-medium mb-1">{t('settings:customOpenAi.customBaseUrl')}</label> |
addressing PR feedback
Description
This PR introduces a new API provider: "Custom OpenAI Compatible". This provider allows users to connect Roo to OpenAI-compatible APIs that have non-standard configurations, such as:
YY-API-KEYinstead ofAuthorization)Bearerprefix)/api/v1/chat/{model_name})This enhances Roo's flexibility to integrate with a wider range of self-hosted LLM routers and third-party services.
This change supports the project roadmap goal of providing "More versatile 'OpenAI Compatible' support".
Changes
CustomOpenAiHandlerinsrc/api/providers/custom-openai.tsto handle custom logic.src/api/index.tsto register the new provider.src/schemas/index.ts.webview-ui/src/components/settings/ApiOptions.tsx) with fields for:Authorization)Bearer, with tooltip)src/api/providers/__tests__/custom-openai.test.ts.claude-3-7-sonnet-20250219.How to Test
npm run build) or run in the Extension Development Host (F5).YY-API-KEY)./api/v1/chat/).<base_url><path_prefix><model_name>) with the correct custom authentication header.Screenshot
https://imgur.com/a/ZQrjvbE
Breaking Changes
None.
Important
Introduces
Custom OpenAI CompatibleAPI provider with custom authentication and URL configurations, updating handler logic, UI, and schemas.CustomOpenAiHandlerincustom-openai.tsto handle custom authentication headers, URL structures, and model paths.custom-openaiprovider inindex.ts.claude-3-7-sonnet-20250219.ApiOptions.tsxto include fields for custom base URL, API key, auth header name, and prefix.custom-openai.test.tsfor handler construction, error handling, and endpoint usage.providerSettingsSchemainschemas/index.tsto include new fields for custom provider.custom-openaitoproviderNamesandPROVIDERSinconstants.ts.This description was created by
for ec18380. It will automatically update as commits are pushed.